import requests from './request'
import mockRequests from './mockAjax'

// 三级联动接口 /api/product/getBaseCategoryList
// axios发送请求返回结果Promise对象
export const reqCategoryList = () => {
  return requests({ url: '/product/getBaseCategoryList', method: 'get' })
}

// 获取首页banner
export const reqGetbannerList = () => {
  return mockRequests({ url: '/banner', method: 'get' })
}

// 获取首页floor
export const reqGetFloorList = () => {
  return mockRequests({ url: '/floor', method: 'get' })
}
// 获取Search页面数据,给接口传递params参数

export const reqGetSearchInfo = (params) => requests({ url: '/list', method: 'post', data: params })

// 获取商品详情，给接口传递params参数
export const reqGetProInfo = (skuId) => requests({ url: `/item/${skuId}`, method: 'get' })
// 将产品添加到购物车中（获取更新某一个产品的个数）/api/cart/addToCart/{ skuId }/{ skuNum }
export const reqAddOrUpdataShopCart = (skuId, skuNum) => requests({
  url: `/cart/addToCart/${skuId}/${skuNum}`,
  method: 'post'
})
// 获取购物车列表数据接口
export const reqCarList = () => requests({ url: '/cart/cartList', method: 'get' })
// 删除购物车数据 /api/cart/deleteCart/{skuId}
export const reqDeleteCarBySkuId = (skuId) => requests({ url: `/cart/deleteCart/${skuId}`, method: 'delete' })
// 切换商品勾选状态 /api/cart/checkCart/{skuId}/{isChecked}
export const reqUpdateCheckedByid = (skuId, isChecked) => requests({
  url: `/cart/checkCart/${skuId}/${isChecked}`,
  method: 'get'
})
// 获取验证码 /api/user/passport/sendCode/{phone}
export const reqGetCode = (phone) => requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' })
// 注册 /api/user/passport/register post
export const reqUserRegister = (data) => requests({ url: `/user/passport/register`, data, method: 'post' })
// 登录 /api/user/passport/login
export const reqUserLogin = (data)=>requests({url:'/user/passport/login',data,method:'post'});
//添加了token校验获取用户登录信息，用户登录只保存用户的tokentoken校验 /api/user/passport/auth/getUserInfo
export const reqUserInfo = ()=>requests({url:'/user/passport/auth/getUserInfo',method:'get'});
//退出登录 /api/user/passport/logout
export const reqLogOut=()=>requests({url:'/user/passport/logout',method:'get'})
// 获取用户地址信息 /api/user/userAddress/auth/findUserAddressList
export const reqAddressInfo=()=>requests({url:'/user/userAddress/auth/findUserAddressList',method:'get'})
// 获取订单交易页信息 /api/order/auth/trade
export const reqOrderInfo=()=>requests({url:'/order/auth/trade',method:'get'})
// 提交订单 /api/order/auth/submitOrder?tradeNo={tradeNo}
export const reqSubmitOrder=(tradeNo,data)=>requests({url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,data,method:'post'})
// 获取订单支付信息 /api/payment/weixin/createNative/{orderId}
export const reqPayInfo=(orderId)=>requests({url:`/payment/weixin/createNative/${orderId}`,method:'get'})
// 查询支付订单状态 /api/payment/weixin/queryPayStatus/{orderId}
export const reqPayStatus=(orderId)=>requests({url:`/payment/weixin/queryPayStatus/${orderId}`,method:'get'})
// 获取我的订单列表 /api/order/auth/{page}/{limit}
export const reqMyOrderList=(page,limit)=>requests({url:`/order/auth/${page}/${limit}`,method:'get'})
